<template>
  <!-- 上传厂家证照的表格modal -->
  <div>
    <basic-modal
      :modalOpt="modal"
      :buttonText="['','关闭']"
      @onMakeSure="onPush"
      @closeModal="closeModal"
      :footer="footer"
    >
      <template #cusBtn>
      </template>
      <template>
        <batch-operat-btn
          v-if="editable"
          :isView="false"
          :addData="true"
          @onAddData="onAddData"
        >
          <template #cusBtn> </template>
        </batch-operat-btn>
        <a-list-info :infoDatas="infoDatas" />
      </template>
    </basic-modal>
  </div>
</template>

<script>
import basicModal from '@/views/app/biz/common/basicModal'
import aListTable from '@/views/app/biz/common/aListTable'
import aListInfo from '@/views/app/biz/common/aListInfo'
import batchOperatBtn from '@/views/app/biz/common/batchOperatBtn'

import {
  getDetailByPid,
} from './saleOrder'

export default {
  components: {
    basicModal,
    aListTable,
    batchOperatBtn,
    aListInfo
  },
  data () {
    return {
      footer: undefined,
      editable: false,
      loading: false,
      modal: {
        modalVisible: false,
        modalTitle: '',
        modalWidth: '80vw',
        maxHeight: '70vh'
      },
      infoDatas: [
        { title: '所属客户采购单号', id: 'purOrderNo', value: '' },
        { title: '销售单号', id: 'saleOrderNo', value: '' },
        { title: '销售单名称', id: 'saleOrderName', value: '' },
        { title: '采购单位备注', id: 'remark', value: '' },
        { title: '商品编号', id: 'saleGoodsCode', value: '' },
        { title: '采购单位商品编号', id: 'purProdCode', value: '' },
        { title: '商品平台编号', id: 'baseCode', value: '' },
        { title: '标准编码', id: 'standardCode', value: '' },
        { title: 'EDI编码', id: 'ediCode', value: '' },
        { title: '品名', id: 'productNameZh', value: '' },
        { title: '通用名', id: 'commonName', value: '' },
        { title: '型号', id: 'model', value: '' },
        { title: '规格', id: 'spec', value: '' },
        { title: '生产厂家代码', id: 'manufacturerCode', value: '' },
        { title: '生产厂家名称', id: 'manufacturerZh', value: '' },
        { title: '批准类型(字典medicalApprovalType)', id: 'approvalType', value: '' },
        { title: '批准号', id: 'approvalNum', value: '' },
        { title: '中标类型', id: 'acquisitionType', value: '' },
        { title: '中标号', id: 'acquisitionCode', value: '' },
        { title: '计量单位', id: 'measurement', value: '' },
        { title: '采购数量', id: 'num', value: '' },
        { title: '单品含税价', id: 'iunitprice', value: '', style: 'fontWeight:bolder', toFixed2: true },
        { title: '含税总价', id: 'totalPrice', value: '', style: 'fontWeight:bolder', toFixed2: true },
        { title: '折扣总金额', id: 'discountAmount', value: '' },
        { title: '税率（百分比）', id: 'taxRate', value: '',type:'percentage' },
        { title: '应付总金额', id: 'dueAmount', value: '' },
        { title: '实付金额', id: 'payableAmount', value: '' },
        { title: '订单状态(字典saleOrderState)', id: 'purOrderState', value: '' },
        { title: '送货类型（字典deliveryType）', id: ' deliveryType', value: '' },
        { title: '配送单号', id: 'deliveryOrderNo', value: '' },
        { title: '已执行配送数量', id: 'execNum', value: '' },
        { title: '销售订单明细单生成时间', id: 'salesaleOrderDetailCreateTime', value: '' },
        { title: '销售订单明细单确认时间', id: 'salesaleOrderDetailCfmTime', value: '' },
        { title: '销售订单明细单完成时间', id: 'salesaleOrderDetailFinTime', value: '' },
      ],

      sData: {
        saleOrderPid: null,
      },
      listdata: [],
      listKey: 0,
      pid: '',
      zzPid: '',
      sysSeq: 0,
      loadings: false,
    }
  },
  computed: {},
  mounted () { },
  methods: {
    // // 弹出模态框
    showModal (val, record) {
      this.pid = val
      this.record = record
      this.modal.modalVisible = true
      this.modal.modalTitle = '查看详情'
      this.getSBypid(val)

    },
    // 关闭模态详细框
    closeModal () {
      this.modal.modalVisible = false
      this.$emit('close')
    },
    closeModal2 () {
      this.modal.modalVisible = false
      this.$emit('ok')
    },
    //
    onAddData () {
      this.$refs.addSellerLicChildModal.addModal(this.pid)
    },

    // 审核
    onPush () {
    },

    // 得到销售订单消息
    async getSBypid (val) {
      let res = await getDetailByPid(val)
      console.log(val, res);
      if (res && res.code && res.code === 'C1') {
        this.sysSeq = res.data.sysSeq
        for (const key in res.data) {
          for (const item of this.infoDatas) {
            if (key == item.id) {
              item.value = res.data[key]
            }
          }
        }
      }
    },
  },
}
</script>

<style>
.recordBox {
  width: 100%;
  min-height: 80px;
}
</style>